package org.linlinjava.litemall.db.service;

import org.linlinjava.litemall.db.dao.AgedmallOrderMsgMapper;
import org.linlinjava.litemall.db.domain.AgedmallOrderMsg;
import org.linlinjava.litemall.db.domain.AgedmallOrderMsgExample;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;

@Service
public class AgedmallOrderMsgService {
    @Resource
    private AgedmallOrderMsgMapper agedmallOrderMsgMapper;

    public void add(AgedmallOrderMsg agedmallOrderMsg) {
        agedmallOrderMsg.setAddTime(LocalDateTime.now());
        agedmallOrderMsg.setUpdateTime(LocalDateTime.now());
        agedmallOrderMsg.setDeleted(false);
        agedmallOrderMsgMapper.insertSelective(agedmallOrderMsg);
    }

    public void update(AgedmallOrderMsg agedmallOrderMsg) {
        agedmallOrderMsg.setUpdateTime(LocalDateTime.now());
        agedmallOrderMsgMapper.updateByPrimaryKeySelective(agedmallOrderMsg);
    }

    public AgedmallOrderMsg queryById(Integer id) {
        return agedmallOrderMsgMapper.selectByPrimaryKey(id);
    }

    public List<AgedmallOrderMsg> queryByStoreId(Integer storeId) {
        AgedmallOrderMsgExample example = new AgedmallOrderMsgExample();
        example.createCriteria().andDeletedEqualTo(false)
                .andStoreIdEqualTo(storeId);
        return agedmallOrderMsgMapper.selectByExample(example);
    }
}
